package com.bosssoft.ct.springcloud.exception;

/**
 * 业务异常代码
 * @author ChenTong
 * @version 1.0
 * @date 2020/6/22 7:31
 * @copyright
 * @modified
 * @see BusinessException
 * @since
 **/
public enum BusinessExceptionCode {

    DATA_OPERATE_FAIL(10000,"数据库操作失败"),
    LOGIN_FAIL(10002,"登录失败"),
    UNDEFINE(900000,"未定义");

    private final int code;

    private final String message;

    BusinessExceptionCode(int code,String message) {
        this.code=code;
        this.message=message;
    }

    public static String msg(int code) {
        for (BusinessExceptionCode businessErrorCode : BusinessExceptionCode.values()) {
            if (businessErrorCode.getCode() == code) {
                return businessErrorCode.message;
            }
        }
        return UNDEFINE.message;
    }

    public int getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

}
